#include<stdio.h>
#include<string.h>
#include<stdlib.h>

// head
int hello(void);
void arrayTest(char * pStr, unsigned char *puStr);

// function
int hello()
{
	printf("hello world\n");
	return 0;
}

// 字符指针及数组类型
void arrayTest(char * pStr, unsigned char *puStr)
{
	int i = 0;
	printf("%s\n", pStr);
	for (size_t i = 0; i < 10; i++)
	{
		printf("%c ", puStr[i]);
	}
	printf("\n");
	
}

// 普通指针
void pointerTest(int * pInt, float * pFloat)
{
	*pInt = 19;
	*pFloat = 28.2;
}
// 字符指针
void mallocTest(char *pStr)
{
	strcpy(pStr, "Happy world");
}

// 结构体
typedef struct _rect
{
	int index;
	char info[20];
	// char info[10];
}Rect;

int readRect(Rect rect)
{
	printf("index:%d\ninfo:%s\n", rect.index, rect.info);
	return 0;
}

// 结构体简单嵌套
typedef struct _rect_nest
{
	Rect rect_c;
	// float nest;
	int nest;
}RectNest;

int readRectRest(RectNest rectnest)
{
	// printf("info:%s\nfloat_nest:%f\n",
	printf("\nindex:%d\ninfo:%s\nfloat_nest:%d\n",
		rectnest.rect_c.index, rectnest.rect_c.info, rectnest.nest);
	return 0;
}